#include <iostream>
#include <vector>
using namespace std;
int main() 
{
    vector<int> v;
    int n, cnt = 0, pre = 0;
    cin >> n;
    string kids;
    cin >> kids;
    for (int i = 0; i < n; i++) 
    {
        if (kids[i] == '0')
            v.emplace_back(i + 1);
        else 
        {
            cnt++;
            if (cnt >= 2)
                v.emplace_back(pre);
            else
                v.emplace_back(0);
            pre = i + 1;
        }

    }
    for (auto e : v)
    {
        if (e)
            cout << e << ' ';
        else
            cout << pre << ' ';

    }
}
